﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using bzxxxt.dal;

namespace bzxxxt.bll
{
    public class BaseBLL
    {        
        private bzxxxtEntities _db = null;
        public bzxxxtEntities DB
        {
            get
            {
                return _db;
            }
        }
        public BaseBLL()
        {
            if (_db == null)
            {
                _db = new bzxxxtEntities();
                ((IObjectContextAdapter)_db).ObjectContext.CommandTimeout = Cfg.TimeOut;           
            }
        }

        public SqlParameter[] GetPagerParameters(string tablName, string columns, string order, string where, int pageSize, int pageIndex, SqlParameter paramTotalCount)
        {
            SqlParameter paramTableName = new SqlParameter("@tableName", tablName);
            SqlParameter paramColumns = new SqlParameter("@columns", "*");
            SqlParameter paramOrder = new SqlParameter("@order", order);
            SqlParameter paramPageSize = new SqlParameter("@pageSize", pageSize);
            SqlParameter paramPageIndex = new SqlParameter("@pageIndex", pageIndex);
            SqlParameter paramWhere = new SqlParameter("@where", where);
            SqlParameter[] paras = new SqlParameter[] { paramTableName, paramColumns, paramOrder, paramPageSize, paramPageIndex, paramWhere, paramTotalCount };
            return paras;
        }
    }
}